package manager.dao.proxy;

import java.util.List;
import manager.dao.impl.MessageDAOImpl;
import manager.database.DatabaseSqlSession;
import manager.vo.Message;

public class MessageDAOProxy {
	private MessageDAOImpl dao = null;
	private MessageDAOProxy() throws Exception{
		this.dao = new MessageDAOImpl(DatabaseSqlSession.getSqlSession());
	}
	public static MessageDAOProxy getInstance() throws Exception{
		return new MessageDAOProxy();
	}
	//查询
    public List<Message> selectMessage(Integer userid){
    	List<Message> list = null;
    	try {
			list = this.dao.selectMessage(userid);
		} catch (Exception e) {
			e.printStackTrace();
		}
    	finally{
    		DatabaseSqlSession.closeSqlSession();
    	}
    	return list;
    }
//    public static void main(String[] args) {
//		try {
//			List<Message> list = MessageDAOProxy.getInstance().selectMessage(4);
//			for (Message message : list) {
//				System.out.println(message.toString());
//			}
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//	}
}
